{template 'web/_header'}
{template 'web/order/tabs'}
<style type='text/css'>
.trhead td {  background:#efefef;text-align: center}
.trbody td {  text-align: center; vertical-align:top;border-left:1px solid #ccc;overflow: hidden;}
.goods_info{position:relative;width:60px;}
.goods_info img {width:50px;background:#fff;border:1px solid #CCC;padding:1px;}
.goods_info:hover {z-index:1;position:absolute;width:auto;}
.goods_info:hover img{width:320px; height:320px;}
</style>
<div class="panel panel-default">
    <div class="panel-body">
        <form action="./index.php" method="get" class="form-horizontal" role="form" id="form1">
            <input type="hidden" name="c" value="site" />
            <input type="hidden" name="a" value="entry" />
            <input type="hidden" name="m" value="sz_yi" />
            <input type="hidden" name="do" value="order" />
            <input type="hidden" name="status" value="{$status}" />
            <input type="hidden" name="agentid" value="{$_GPC['agentid']}" />
            <input type="hidden" name="refund" value="{$_GPC['refund']}" />  
            <div class="form-group">
                <div class="col-sm-8 col-lg-9 col-xs-12">
                    <div class='input-group'>
                        <div class='input-group-addon'>订单号</div>
                        <input class="form-control" name="keyword" type="text" value="{$_GPC['keyword']}" placeholder="订单号">
                        <div class='input-group-addon'>快递单号</div>
                        <input class="form-control" name="expresssn" type="text" value="{$_GPC['expresssn']}" placeholder="快递单号">
                        <div class='input-group-addon'>用户信息</div>
                        <input class="form-control" name="member" type="text" value="{$_GPC['member']}" placeholder="用户手机号/姓名/昵称, 收件人姓名/手机号 ">
                        <div class='input-group-addon'>支付方式</div>
                        <select name="paytype" class="form-control">
                            <option value="" {if $_GPC['paytype']==''}selected{/if}>不限</option>
                            {loop $paytype $key $type}
                            <option value="{$key}" {if $_GPC['paytype'] == "$key"} selected="selected" {/if}>{$type['name']}</option>
                            {/loop}
                        </select>
                    </div>
                </div>
            </div> 
			<div class='form-group'>
				  <div class="col-sm-8 col-lg-9 col-xs-12">
                    <div class='input-group'>
				   <div class='input-group-addon'>核销员</div>
                        <input class="form-control" name="saler" type="text" value="{$_GPC['saler']}" placeholder="核销员昵称/姓名/手机号">
						<div class='input-group-addon'>核销门店</div>
                        <select name="storeid" class="form-control">
                            <option value="" ></option>
			 {loop $stores $store}
			<option value="{$store['id']}" {if $_GPC['storeid'] ==$store['id']} selected="selected" {/if}>{$store['storename']}</option>
			{/loop}
                        </select>
			</div>
				  </div>
			</div>
            <div class="form-group">

                <div class="col-sm-6">

                    <div class='input-group'>

                        <div class='input-group-addon'>下单时间
                            <label class='radio-inline' style='margin-top:-7px;'>
                                <input type='radio' value='0' name='searchtime' {if $_GPC['searchtime']=='0'}checked{/if}>不搜索
                            </label>
                            <label class='radio-inline'  style='margin-top:-7px;'>
                                <input type='radio' value='1' name='searchtime' {if $_GPC['searchtime']=='1'}checked{/if}>搜索
                            </label>
                        </div>
                        {php echo tpl_form_field_daterange('time', array('starttime'=>date('Y-m-d H:i', $starttime),'endtime'=>date('Y-m-d H:i', $endtime)),true);}


                    </div>
                </div>

                {if !empty($agentid) && $level>0}   
                <div class="col-sm-3">
                    <div class='input-group'>
                        <div class='input-group-addon'>分销订单级数</div>
                        <select name="olevel" class="form-control">
                            <option value="" >不限</option>
                            <option value="1" {if $_GPC['olevel'] ==1} selected="selected" {/if}>一级订单</option>
                            <option value="2" {if $_GPC['olevel'] ==2} selected="selected" {/if}>二级订单</option>
                            <option value="3" {if $_GPC['olevel'] ==3} selected="selected" {/if}>三级订单</option>
                        </select>
                    </div>    </div>
                {/if}

            </div>

            <div class="form-group">

                <div class="col-sm-7 col-lg-9 col-xs-12">
                    <button class="btn btn-default"><i class="fa fa-search"></i> 搜索</button>
                    <input type="hidden" name="token" value="{$_W['token']}" />
                    <button type="submit" name="export" value="1" class="btn btn-primary">导出 Excel</button>
                </div>
            </div>
     
        </form>
    </div>
</div>

 
        <table class='table' style='float:left;border:1px solid #ccc;margin-bottom:5px;table-layout: fixed'>
                <tr class='trhead'>
                    <td colspan='2' style='width:460px;text-align: left'>订单数: {$total} 订单金额: {$totalmoney}</td>
                    <td  style='width:150px;text-align:left;'>单价/数量</td>
                    <td  >买家</td>
                    <td >支付方式/配送方式</td>
                    <td  style='width:200px;'>价格</td>             
                    <td >状态</td>
                    <td>操作</td>
                </tr>
            </table>
          
                {loop $list $item}
  <table class='table' style='float:left;border:1px solid #ccc;margin-top:5px;margin-bottom:0px;table-layout: fixed;'>
                <tr >
                    <td colspan='8'  style='border-bottom:1px solid #ccc;background:#efefef;' > 
                        <b>订单编号:</b>  {$item['ordersn']}     
                        <b>下单时间:  </b>{php echo date('Y-m-d H:i:s', $item['createtime'])}
                         {if !empty($item['refundid'])}<label class='label label-danger'>退款申请</label>{/if} 
						 {if !empty($agentid)}
						 <b>分销订单级别:</b> {$item['level']}级 <b>分销佣金:</b> {$item['commission']} 元
						
						 {/if}
						 {if !empty($level)}
						    
						      {if empty($agentid)}
							  {if $item['commission1']!=-1}<b>1级佣金:</b> {$item['commission1']} 元 {/if}
							  {if $item['commission2']!=-1}<b>2级佣金:</b> {$item['commission2']} 元 {/if}
							  {if $item['commission3']!=-1}<b>3级佣金:</b> {$item['commission3']} 元 {/if}
						      {/if}
						      {if !empty($item['agentid'])}
							{ifp 'commission.changecommission'}
							<a href='javascript:;' class='btn btn-default' onclick="commission_change('{$item['id']}')">修改佣金</a>
							{/if}
						      {/if}
						 
						 {/if}
						 
                    <td style='border-bottom:1px solid #ccc;background:#efefef;text-align: center' >
                          {if empty($item['statusvalue'])}
                           {ifp 'order.op.close'}
                                  <a class="btn btn-default btn-sm" href="javascript:;" onclick="$('#modal-close').find(':input[name=id]').val('{$item['id']}')" data-toggle="modal" data-target="#modal-close">关闭订单</a>
                            {/if}
                            {/if}
                    </td>
                         
                </tr>
  </table>
	  <table class='table' style='float:left;border:1px solid #ccc;border-top:none;table-layout: fixed;'>


                {loop $item['goods'] $k $g}
                <tr class='trbody'>
                    <td class="goods_info">
						 <img src="{php echo tomedia($g['thumb'])}"> 
					</td>
                    <td valign='top'  style='border-left:none;text-align: left;width:400px;'  >
						{$g['title']}{if !empty($g['optiontitle'])}<br/><span class="label label-primary">{$g['optiontitle']}</span>{/if}
						<br/>{$g['goodssn']}
					</td>
                    <td style='border-left:none;text-align:left;width:150px'>原价: {php echo number_format( $g['price']/$g['total'],2)} <br />应付: {php echo number_format($g['realprice']/$g['total'],2)}
		<br/>数量: {$g['total']}			 
					</td>
                    
                    {if $k==0}
                    <td rowspan="{php echo count($item['goods'])}" >
						 {ifp 'member.member.edit'}
						 <a href="{php echo $this->createWebUrl('member/list',array('op'=>'detail', 'id'=>$item['mid']))}"> {$item['nickname']}</a>
						 {else}
							 {$item['nickname']}
							 {/if}
							 
							 <br/>
						{$item['addressdata']['realname']}<br/>{$item['addressdata']['mobile']}</td>
                    <td rowspan="{php echo count($item['goods'])}"    >
						 <label class='label label-{$item['css']}'>{$item['paytype']}</label><br/>
									   {$item['dispatchname']}
									   {if $item['addressid']!=0 && $item['statusvalue']>=2}<br/>
									   <button type='button' class='btn btn-default btn-sm' onclick='express_find(this,"{$item['id']}")' >查看物流</button>
									   {/if}
					</td>
                    <td  rowspan="{php echo count($item['goods'])}" style='width:200px;'>
						<table style='width:100%;'>
							<tr>
								<td  style='border:none;text-align:right;'>商品小计：</td>
								<td  style='border:none;text-align:right;;'>￥{php echo number_format( $item['goodsprice'] ,2)}</td>
							</tr>
							<tr>
								<td  style='border:none;text-align:right;'>运费：</td>
								<td  style='border:none;text-align:right;;'>￥{php echo number_format( $item['olddispatchprice'],2)}</td>
							</tr>
							{if $item['discountprice']>0}
							<tr>
								<td  style='border:none;text-align:right;'>会员折扣：</td>
								<td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['discountprice'],2)}</td>
							</tr>
							{/if}
							{if $item['deductprice']>0}
							<tr>
								<td  style='border:none;text-align:right;'>积分抵扣：</td>
								<td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['deductprice'],2)}</td>
							</tr>
							{/if}
							{if $item['deductcredit2']>0}
							<tr>
								<td  style='border:none;text-align:right;'>余额抵扣：</td>
								<td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['deductcredit2'],2)}</td>
							</tr> 
							{/if}
							{if $item['deductenough']>0}
							<tr>
								<td  style='border:none;text-align:right;'>满额立减：</td>
								<td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['deductenough'],2)}</td>
							</tr>
							{/if}
							{if $item['couponprice']>0}
							<tr>
								<td  style='border:none;text-align:right;'>优惠券优惠：</td>
								<td  style='border:none;text-align:right;;'>-￥{php echo number_format( $item['couponprice'],2)}</td>
							</tr>
							{/if}
							{if intval($item['changeprice'])!=0}
							<tr>
								<td  style='border:none;text-align:right;'>卖家改价：</td>
								<td  style='border:none;text-align:right;;'><span style="{if 0<$item['changeprice']}color:green{else}color:red{/if}">{if 0<$item['changeprice']}+{else}-{/if}￥{php echo number_format(abs($item['changeprice']),2)}</span></td>
							</tr>
						         {/if}
							{if intval($item['changedispatchprice'])!=0}
							<tr>
								<td  style='border:none;text-align:right;'>卖家改运费：</td>
								<td  style='border:none;text-align:right;;'><span style="{if 0<$item['changedispatchprice']}color:green{else}color:red{/if}">{if 0<$item['changedispatchprice']}+{else}-{/if}￥{php echo abs($item['changedispatchprice'])}</span></td>
							</tr>
						         {/if} 
						<tr>
								<td style='border:none;text-align:right;'>应收款：</td>
								<td  style='border:none;text-align:right;color:green;'>￥{php echo number_format($item['price'],2)}</td>
							</tr>
									{ifp 'order.op.changeprice'}
			{if empty($item['statusvalue'])}
							<tr>
								<td style='border:none;text-align:right;'></td>
								<td  style='border:none;text-align:right;color:green;'><a href="javascript:;" class="btn btn-link " onclick="changePrice('{$item['id']}')">修改价格</a></td>
							</tr>
							{/if}  {/if}
						</table>
 				 
				 
	 
                    </td>
                    <td   rowspan="{php echo count($item['goods'])}" ><label class='label label-{$item['statuscss']}'>{$item['status']}</label><br />
                    <a href="{php echo $this->createWebUrl('order', array('op' => 'detail', 'id' => $item['id']))}"   >查看详情</a></td>
 <td   rowspan="{php echo count($item['goods'])}" >
{template 'web/order/ops'}
 

 </td>
            {/if} 
                                                                                                                  </tr>
                                                                                                                  {/loop}
   </table>

                                                                                                                  {/loop}

                    {$pager}
         {template 'web/order/modals'}
		  {if  p('commission')}
		  
		   {template 'commission/changecommission'}
		  {/if}
        {template 'web/_footer'}
